# coding=utf-8

import sys
import os
import string
from traverse.crawler import Crawler
'''
应用页面爬虫，用于自动遍历应用相关页面所有元素
'''

class AppCrawler(object):
    
    def __init__(self, data):
        self.serial = data.get('serial')
        self.conf = data.get('conf') or os.path.join(os.path.dirname(__file__),'conf.yml')
    
    def run(self):
        Crawler(self.serial,self.conf).start()
    
def main(args):
    data = {}
    if len(args) > 1:
        for arg in args[1:]:
            if string.find(arg, '-serial=') == 0:
                data['serial'] = arg[len('-serial='):]
            elif string.find(arg, '-conf=') == 0:
                data['conf'] = arg[len('-conf='):]
    AppCrawler(data).run()

if __name__ == '__main__':
    main(sys.argv)
    